package com.nuoniu.sibanyun.mapper.erp.in;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nuoniu.sibanyun.entity.erp.in.InRdStyle;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 出入库类型 Mapper 接口
 * </p>
 *
 * @author baiqiang
 * @since 2020-09-25
 */
public interface InRdStyleMapper extends BaseMapper<InRdStyle> {

    @Update("update scb_rd_style set parent_ids=REPLACE(parent_ids, #{parentIds}, #{newParentIds}), tree_names=REPLACE(tree_names, #{treeNames}, #{newTreeNames}) " +
            "where  FIND_IN_SET(#{id}, parent_ids) or id = #{id}")
    void updateChildrenParentIds(Long id, String parentIds, String treeNames, String newParentIds, String newTreeNames);

    @Select("select * from scb_rd_style where parent_id=#{parentId}")
    List<InRdStyle> getStyleByParentId(Long parentId);

    @Select("select * from scb_rd_style where code=#{code} and company_id=#{companyId}")
    InRdStyle getByCode(InRdStyle inRdStyle);

    @Select("select * from scb_rd_style where name=#{name} and company_id=#{companyId}")
    InRdStyle getByName(InRdStyle inRdStyle);
}
